#include<bits/stdc++.h>
using namespace std;
long long t,n,m,l,vm,d[100005],v[100005],a[100005],p[100005],sum,summ;
bool flag=true,exist[100005];
struct sss{
    long long start,finish;
};
sss tf[100005];
bool cmp(sss a,sss b){
    if(a.finish!=b.finish) return a.finish<b.finish;
    return a.start<b.start;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    for(long long z=1;z<=t;z++){
        cin>>n>>m>>l>>vm;
        for(long long i=1;i<=n;i++) cin>>d[i]>>v[i]>>a[i];
        for(long long i=1;i<=m;i++){
            cin>>p[i];
            exist[i]=false;
        }
        sum=0;
        summ=0;
        for(long long i=1;i<=n;i++){
            if(a[i]>=0){
                for(long long j=1;j<=m;j++){
                    if(d[i]<=p[j]){
                        long long s=p[j]-d[i];
                        long long svt=v[i]*v[i]+2*a[i]*s;
                        if(svt>vm*vm){
                            sum++;
                            tf[sum].start=j;
                            tf[sum].finish=m;
                            break;
                        }
                    }
                }
            }
            else {
                flag=true;
                for(long long j=1;j<=m;j++){
                    if(d[i]<=p[j]){
                        long long s=p[j]-d[i];
                        long long svt=v[i]*v[i]+2*a[i]*s;
                        if(svt>vm*vm){
                            if(flag){
                               sum++;
                               tf[sum].start=j;
                               flag=false;
                            }
                            tf[sum].finish=j;
                        }
                        else break;
                    }
                }
            }
        }
        sort(tf+1,tf+1+sum,cmp);
        for(long long j=1;j<=sum;j++){
            flag=true;
            for(long long x=tf[j].start;x<=tf[j].finish;x++){
                if(exist[x]){
                    flag=false;
                    break;
                }
            }
            if(flag){
                exist[tf[j].finish]=true;
                summ++;
            }
        }
        cout<<sum<<" "<<m-summ<<"\n";
    }
    return 0;
}
